package net.homelinux.ajay.net.ondisk.model.client;


import com.google.gwt.http.client.Header;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;


public class HttpHeadMeta extends Link implements RequestCallback {

  private Header[] responseHeaders;

  public void onError(Request request, Throwable exception) {
    super.setHttpLoadStatus(Link.ERROR);
    fireChangeListeners();
//    synchronized(this){
//      notifyAll();
//    }
  }

  public void onResponseReceived(Request request, Response response) {
    setResponse(response);
    super.setHttpLoadStatus(Link.LOADED);
//  synchronized(this){
//    notifyAll();
//  }
    fireChangeListeners();
  }
  
  protected void setResponse(Response response) {
    this.responseHeaders = response.getHeaders();
    System.out.println(response.getHeadersAsString());
    try {
      super.setSize( Integer.parseInt(response.getHeader("Content-Length")));
    } catch (NumberFormatException e) {
    }
    
  }
        
}
